package com.cloud.lawcase.api.mapper;

import java.util.List;

import com.cloud.lawcase.common.driver.SimpleInlangDriver;
import org.apache.ibatis.annotations.*;

import com.cloud.lawcase.api.entity.TcLawClDetail;
import com.cloud.lawcase.common.openapi.OpenApiLawCauseClBean;
import com.cloud.lawcase.common.utils.BaseMapperHelper;

public interface TcLawClDetailMapper extends BaseMapperHelper<TcLawClDetail> {

	@Delete("delete from tc_law_cl_detail where cause_id = #{causeId}")
	void deleteByCauseId(long causeId);

	@Select("select obj_type_name, top_limit, case top_unit when 1 then '元' when 2 then '倍' when 3 then '元/单位' end top_unit,"
			+ "lower_limit, case lower_unit when 1 then '元' when 2 then '倍' when 3 then '元/单位' end lower_unit "
			+ "from tc_law_cl_detail where punish_id = #{punishId}")
	@Results({ @Result(column = "obj_type_name", property = "objTypeName", javaType = String.class),
			@Result(column = "top_limit", property = "topLimit", javaType = Double.class),
			@Result(column = "top_unit", property = "topUnit", javaType = String.class),
			@Result(column = "lower_limit", property = "lowerLimit", javaType = Double.class),
			@Result(column = "lower_unit", property = "lowerUnit", javaType = String.class) })
	List<OpenApiLawCauseClBean> listCLDetailByPunishId(Long punishId);

	@Select("select cause_id from tc_dic_law_cause where cause_code in (#{codes})")
	@Lang(SimpleInlangDriver.class)
	List<Long> listCauseIdByCauseCode(@Param("codes") List<String> causeCodes);
}